From e0ded894d919c03ba88f24849a35e7a98b3e2304 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 29 Apr 2012 22:10:11 +0200 Subject: [PATCH] (bug 30488) API now allows listing of backlinks/embeddedin/imageusage per pageid Move the possibles errors set by ApiBase::getTitleOrPageId to ApiBase::getTitleOrPageIdErrorMessages and remove it from used modules Change-Id: If037e04665d2524c1f2476bc7996d9573753a4b8 --- RELEASE-NOTES-1.20 | 1 + includes/api/ApiBase.php | 10 +++++++-- includes/api/ApiDelete.php | 2 -- includes/api/ApiEditPage.php | 2 -- includes/api/ApiProtect.php | 2 -- includes/api/ApiQueryBacklinks.php | 28 +++++++++++------------- includes/api/ApiQueryCategoryMembers.php | 1 - 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index c77a4eb545..1b35ad5c0f 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -103,6 +103,7 @@ production. * (bug 32497) API now allows changing of protection level using pageid * (bug 32498) API now allows comparing pages using pageids * (bug 30975) API import of pages with invalid characters in this wiki leads to Fatal Error +* (bug 30488) API now allows listing of backlinks/embeddedin/imageusage per pageid === Languages updated in 1.20 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 1103814143..fc2ef77247 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -723,8 +723,14 @@ abstract class ApiBase extends ContextSource { /** * @return array */ - public function getTitleOrPageIdErrorMessage( ) { - return $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ); + public function getTitleOrPageIdErrorMessage() { + return array_merge( + $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ), + array( + array( 'invalidtitle', 'title' ), + array( 'nosuchpageid', 'pageid' ), + ) + ); } /** diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 15c1f82312..21e7b80927 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -230,8 +230,6 @@ class ApiDelete extends ApiBase { return array_merge( parent::getPossibleErrors(), $this->getTitleOrPageIdErrorMessage(), array( - array( 'invalidtitle', 'title' ), - array( 'nosuchpageid', 'pageid' ), array( 'notanarticle' ), array( 'hookaborted', 'error' ), array( 'delete-toobig', 'limit' ), diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index b45f351b51..11f4757119 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -371,9 +371,7 @@ class ApiEditPage extends ApiBase { return array_merge( parent::getPossibleErrors(), $this->getTitleOrPageIdErrorMessage(), array( - array( 'nosuchpageid', 'pageid' ), array( 'missingtext' ), - array( 'invalidtitle', 'title' ), array( 'createonly-exists' ), array( 'nocreate-missing' ), array( 'nosuchrevid', 'undo' ), diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 57bf111c2e..97e79ffe18 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -192,8 +192,6 @@ class ApiProtect extends ApiBase { return array_merge( parent::getPossibleErrors(), $this->getTitleOrPageIdErrorMessage(), array( - array( 'invalidtitle', 'title' ), - array( 'nosuchpageid', 'pageid' ), array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ), array( 'create-titleexists' ), array( 'missingtitle-createonly' ), diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 381ef550d3..bf9aa3d6b3 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -369,14 +369,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { if ( !is_null( $this->params['continue'] ) ) { $this->parseContinueParam(); } else { - if ( $this->params['title'] !== '' ) { - $title = Title::newFromText( $this->params['title'] ); - if ( !$title ) { - $this->dieUsageMsg( array( 'invalidtitle', $this->params['title'] ) ); - } else { - $this->rootTitle = $title; - } - } + $this->rootTitle = $this->getTitleOrPageId( $this->params ); } // only image titles are allowed for the root in imageinfo mode @@ -436,7 +429,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $retval = array( 'title' => array( ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_REQUIRED => true + ), + 'pageid' => array( + ApiBase::PARAM_TYPE => 'integer', ), 'continue' => null, 'namespace' => array( @@ -468,7 +463,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { public function getParamDescription() { $retval = array( - 'title' => 'Title to search', + 'title' => "Title to search. Cannot be used together with {$this->bl_code}pageid", + 'pageid' => "Pageid to search. Cannot be used together with {$this->bl_code}title", 'continue' => 'When more results are available, use this to continue', 'namespace' => 'The namespace to enumerate', ); @@ -499,11 +495,13 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'invalidtitle', 'title' ), - array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ), - array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - ) ); + return array_merge( parent::getPossibleErrors(), + $this->getTitleOrPageIdErrorMessage(), + array( + array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ), + array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), + ) + ); } public function getExamples() { diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 7f0b827785..8fff94dc79 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -374,7 +374,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { array( array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ), array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), - array( 'nosuchpageid', 'pageid' ), ) ); } -- 2.20.1